package cn.iocoder.yudao.module.famous.doctor.dal.mysql.extraction;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.security.core.LoginUser;
import cn.iocoder.yudao.module.famous.doctor.dal.dataobject.extraction.ExtractionDO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.famous.doctor.controller.admin.extraction.vo.*;
import org.apache.ibatis.annotations.Param;

/**
 * 开方 Mapper
 *
 * @author 档案
 */
@Mapper
public interface ExtractionMapper extends BaseMapperX<ExtractionDO> {

    default PageResult<ExtractionDO> selectPage(ExtractionPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ExtractionDO>()
                .eqIfPresent(ExtractionDO::getIllness, reqVO.getIllness())
                .eqIfPresent(ExtractionDO::getTitle, reqVO.getTitle())
                .eqIfPresent(ExtractionDO::getContent, reqVO.getContent())
                .eqIfPresent(ExtractionDO::getDosage, reqVO.getDosage())
                .eqIfPresent(ExtractionDO::getDailyConsumption, reqVO.getDailyConsumption())
                .eqIfPresent(ExtractionDO::getMattersAttention, reqVO.getMattersAttention())
                .eqIfPresent(ExtractionDO::getUseBook, reqVO.getUseBook())
                .betweenIfPresent(ExtractionDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(ExtractionDO::getPatientId, reqVO.getPatientId())
                .eqIfPresent(ExtractionDO::getUsage, reqVO.getUsage())
                .orderByDesc(ExtractionDO::getId));
    }

    default List<ExtractionDO> selectList(ExtractionExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<ExtractionDO>()
                .eqIfPresent(ExtractionDO::getIllness, reqVO.getIllness())
                .eqIfPresent(ExtractionDO::getTitle, reqVO.getTitle())
                .eqIfPresent(ExtractionDO::getContent, reqVO.getContent())
                .eqIfPresent(ExtractionDO::getDosage, reqVO.getDosage())
                .eqIfPresent(ExtractionDO::getDailyConsumption, reqVO.getDailyConsumption())
                .eqIfPresent(ExtractionDO::getMattersAttention, reqVO.getMattersAttention())
                .eqIfPresent(ExtractionDO::getUseBook, reqVO.getUseBook())
                .betweenIfPresent(ExtractionDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(ExtractionDO::getPatientId, reqVO.getPatientId())
                .eqIfPresent(ExtractionDO::getUsage, reqVO.getUsage())
                .orderByDesc(ExtractionDO::getId));
    }

    List<ExtractionDO> selectextractioContent(@Param("param") LoginUser loginUser);

    IPage<ExtractionDO> selectIpage(Page<Object> objectPage,@Param("userId")  Long loginUserId, @Param("param") ExtractionPageReqVO pageVO);
}
